<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/mui.css"/>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/general.css"/>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hbg">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
		    <h1 class="mui-title">模板</h1>
		</header>
		<div class="mui-content">
		    
		    
		    
		    
		    
		</div>
		<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript">
			window.onload = function(){
				
				var list = ['1','2','3','4','5']
				var list2 = [
					{id:1},
					{id:2},
					{id:3},
					{id:4},
					{id:5}
				]
				console.log(get_is_str("1",list))
				console.log(get_is_str2(6,list2))
				console.log(get_is_str3(2,list2))
				console.log(get_is_str3(6,list2))
			}
			
			//查看数组中是否有值
			function get_is_str(val,list){
				var flag = false;
				list.forEach(function(item,index){
					if(val == item){
						flag = true;
						return false;
					}
				})
				return flag;
			}
			//查看数组中是否有对象中的id
			function get_is_str2(val,list){
				var flag = false;
				list.forEach(function(item,index){
					if(val == item.id){
						flag = true;
						return false;
					}
				})
				return flag;
			}
			
			//查看数组中对象中的id的下标，没有就是-1
			function get_is_str3(val,list){
				var flag = -1;
				list.forEach(function(item,index){
					if(val == item.id){
						flag = index;
						return false;
					}
				})
				return flag;
			}
		</script>
	</body>

</html>